Skip to content

Add documentation about OpenXR spatial entities #11015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BastiaanOlij
Copy link
Contributor

This PR adds documentation for the spatial entities implementation being added here: godotengine/godot#107391

@BastiaanOlij BastiaanOlij added this to the 4.x milestone Jun 11, 2025
@BastiaanOlij BastiaanOlij self-assigned this Jun 11, 2025
@BastiaanOlij BastiaanOlij added enhancement topic:xr Related to XR documentation labels Jun 11, 2025
@AThousandShips AThousandShips added the waiting on PR merge PR's that can't be merged until an engine PR is merged first label Jun 11, 2025
Copy link

@JD-The-65th JD-The-65th left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed a few grammatical issues and typos so I wanted to make a review addressing some of them. I saw that it was also a commonality in this PR to omit commas after dependent clauses, so I left in 2 cases where I noticed it occurred, but I can go back and mark more where I noticed them.

OpenXR spatial entities
=======================

For any sort of augemented reality application you need to access real world information and be able to

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo, "augemented" should be "augmented."

It has a very modular design. The core of the API defines how real world entities are structured,
how they are found and how information about them is stored and accessed.

Various extensions are added ontop that implement specific systems such as marker tracking,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a space between "on top."

Comment on lines +236 to +237
Spatial anchors allow us to map real world location in our virtual world in such a way that the
XR runtime will keep track of these locations and adjust them as needed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use of singular "location" in "real world location" but use of plural "locations" in "... will keep track of these locations"


Spatial anchors allow us to map real world location in our virtual world in such a way that the
XR runtime will keep track of these locations and adjust them as needed.
If supported anchors can be made persistent which means the anchors will be recreated in the correct

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gets nitpicky since it's been a commonality in this PR to not include commas after dependent clauses but this is my first time noticing it.

Original comment was

Add a comma after "If supported."

Comment on lines +248 to +250
When needed the location of the spatial anchor will be updated automatically, the pose on the
related tracker will be updated and thus the :ref:`XRAnchor3D<class_XRAnchor3D>` node will
reposition.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kinda nitpicky, but I would write it to add a comma after "When needed," and change the comma after "automatically" to a period to prevent this sentence from being a run on.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, looking at it again, the comma after automatically would probably be better as a semicolon ';' instead of a period.

related tracker will be updated and thus the :ref:`XRAnchor3D<class_XRAnchor3D>` node will
reposition.

When a spatial anchor has been made persistent a Universally Unique Identifier (or UUID) is

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gets nitpicky since it's been a commonality in this PR to not include commas after dependent clauses but this is my second(ish) time noticing it.

Original comment was

Comma after persistent as "When a spatial anchor has been made persistent" is a dependent clause.



Finally we can process our snapshot. Note that we are using :ref:`OpenXRAnchorTracker<class_OpenXRAnchorTracker>`
as our tracker class as this already has all the support for anchors build in.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"build in" should be "built in" since it's past tense.

With April tags and Aruco markers binary data is encoded based which you again can access when a marker is found,
however you need to configure the detection with the correct decoding format.

As an example we'll create a spatial context that will find QR codes adn Aruco markers.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo, "adn" should be "and."

Some XR runtimes do require vendor extensions to enable and/or configure this process
but the data will be exposed through this extension.

The code we write up above for the spatial manager will already detect our new planes.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"write" probably should be "wrote" for past tense.

@AThousandShips AThousandShips removed this from the 4.x milestone Jun 12, 2025
Copy link
Member

@AThousandShips AThousandShips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do a pass to improve sentence structure as well later

extends Node3D

## Signals a new spatial entity node was added.
signal added_spatial_entity(node : XRNode3D)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
signal added_spatial_entity(node : XRNode3D)
signal added_spatial_entity(node: XRNode3D)

For all

signal removed_spatial_entity(node : XRNode3D)

## Scene to instantiate for spatial anchor entities.
@export var spatial_anchor_scene : PackedScene
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@export var spatial_anchor_scene : PackedScene
@export var spatial_anchor_scene: PackedScene

For all

## Scene to instantiate for mark tracking spatial entities.
@export var marker_tracker_scene : PackedScene

# Trackers we manage nodes for
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Trackers we manage nodes for
# Trackers we manage nodes for.

For all

- Description
* - OPENXR_SPATIAL_COMPONENT_TYPE_MARKER
- :ref:`OpenXRSpatialComponentMarkerList<class_OpenXRSpatialComponentMarkerList>`
- Provides us with the type, id (Aruco and April Tag) and/or data (QR Code) for each marker.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Provides us with the type, id (Aruco and April Tag) and/or data (QR Code) for each marker.
- Provides us with the type, ID (Aruco and April Tag) and/or data (QR Code), for each marker.

=======================

For any sort of augemented reality application you need to access real world information and be able to
track real world locations. OpenXRs spatial entities API was introduced for this exact purpose.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
track real world locations. OpenXRs spatial entities API was introduced for this exact purpose.
track real world locations. OpenXR's spatial entities API was introduced for this exact purpose.

# it will exit if we've called it too early.
_setup_spatial_context()

func _exit_tree():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func _exit_tree():
func _exit_tree():


func _exit_tree():
if spatial_context:
# disconnect from our discovery signal.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# disconnect from our discovery signal.
# Disconnect from our discovery signal.

# And cleanup our snapshot
OpenXRSpatialEntityExtension.free_spatial_snapshot(snapshot)

func _process_snapshot(p_snapshot):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func _process_snapshot(p_snapshot):
func _process_snapshot(snapshot):

var marker_list : OpenXRSpatialComponentMarkerList = OpenXRSpatialComponentMarkerList.new()
result_data.push_back(marker_list)

# Add in our bounded 2d component data.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Add in our bounded 2d component data.
# Add our bounded 2D component data.

# Copy the state
entity_tracker.spatial_tracking_state = entity_state

# Only if we're tracking, we should query the rest of our components.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Only if we're tracking, we should query the rest of our components.
# If we're tracking, we should query the rest of our components.

Or

Suggested change
# Only if we're tracking, we should query the rest of our components.
# Only if we're tracking should we query the rest of our components.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement topic:xr Related to XR documentation waiting on PR merge PR's that can't be merged until an engine PR is merged first
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants